/*
 * Copyright 2003 Program of Computer Graphics, Cornell University
 *     580 Rhodes Hall
 *     Cornell University
 *     Ithaca NY 14853
 * Web: http://www.graphics.cornell.edu/
 * 
 * Not for commercial use. Do not redistribute without permission.
 */

/* Aspects of ray system.

  - Optimize for incoherent rays and "cache cold" ray tracing 
     ie Do not optimize assuming that rays will or can be ordered for maximum coherence
  - KDTree nodes store float split value and two pointers (left & right)
    - Eliminates need for extra node at leaves, node points directly to geometry list
    - 12 bytes per node packed into groups of 10 occuping one 128byte cacheline
    - Packed by chunked breadth-first or most-likely-first for memory coherence
  - Optimized tree-traversal routine and eliminated some unpredictable branches
    - Converted control-dependencies to data-dependencies for 
      - Nodes that are not intersected by ray (tExit >= tEntry)
      - Empty leaf nodes
    - Placed 2bit type field in unused low bits of pointer to node
      - Allow early resolution of remaining unpredictable branch (leaf or interior node)
  - SIMD code for triangles (packed in groups of 4) 
  - Hooks provided for handling other types of geometry (although optimized for triangles)
    - Parallelogram implemented as an example
  - Ability to cleanly delete and/or rebuild KDTree and geometry
  - Thread-safe ray intersection
  - Force ray direction components to be non-zero to eliminate rare corner cases
    - Change is at limits of float precision and should not alter results significantly
  - Worked on optimizing build times, but more work is required

  - compiler flags: /G7 /O3 /QxW

  Future
  - Try large pages to make prefetching more effective, but requires future OS support
  - Try allowing multiple trees for dynamic vs. static parts of scene
  - Allow transforms (or rays) for dynamic objects


  */
